﻿using AutoMapper;
using KayakMes.Common.Result;
using KayakMes.RBAC.Application.Input;
using KayakMes.RBAC.Application.OUT;
using KayakMes.RBAC.Application.Supper;
using KayakMes.RBAC.Doamin;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;

namespace KayakMes.RBAC.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SupperController : ControllerBase
    {
        private readonly ISupperServer _supperServer;
        public SupperController(ISupperServer supperServer)
        {
            _supperServer = supperServer;
        }

        /// <summary>
        /// 添加供应商
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpPost]
        public ApiResult<int> AddSupper([FromBody]AddsupperInput input)
        {
            return _supperServer.AddSupper(input);
        }
        /// <summary>
        /// 获取供应商 下拉列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiResult<List<SupperXiaOUT>> GetSupper()
        {
           return _supperServer.GetSupper();
        }
        /// <summary>
        /// 获取供应商详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiResult<SupperOut> GetSupperById([FromQuery]long id)
        {
            return _supperServer.GetSupperById(id);
        }
        /// <summary>
        /// 获取供应商列表分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="SupperCoide"></param>
        /// <param name="SupperName"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiPaging<SupperOut> GetSupperList([FromQuery]int pageIndex, int pageSize, string? SupperCoide, string? SupperName)
        {
           return _supperServer.GetSupperList(pageIndex, pageSize, SupperCoide, SupperName);
        }
        /// <summary>
        /// 修改供应商
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpPost]
        public ApiResult<int> UpdateSupper(UpdateSupperInput input)
        {
            
            return _supperServer.UpdateSupper(input);
        }
    }
}
